package com.ruoyi.store.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.store.domain.StockTakingDetail;
import com.ruoyi.store.service.IStockTakingDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 库存盘点详情Controller
 * 
 * @author lmj
 * @date 2024-11-04
 */
@RestController
@RequestMapping("/StockTakingDetail")
public class StockTakingDetailController extends BaseController
{
    @Autowired
    private IStockTakingDetailService stockTakingDetailService;

    /**
     * 查询库存盘点详情列表
     */
    @RequiresPermissions("store:StockTakingDetail:list")
    @GetMapping("/list")
    public TableDataInfo list(StockTakingDetail stockTakingDetail)
    {
        startPage();
        List<StockTakingDetail> list = stockTakingDetailService.selectStockTakingDetailList(stockTakingDetail);
        return getDataTable(list);
    }

    /**
     * 导出库存盘点详情列表
     */
    @RequiresPermissions("store:StockTakingDetail:export")
    @Log(title = "库存盘点详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockTakingDetail stockTakingDetail)
    {
        List<StockTakingDetail> list = stockTakingDetailService.selectStockTakingDetailList(stockTakingDetail);
        ExcelUtil<StockTakingDetail> util = new ExcelUtil<StockTakingDetail>(StockTakingDetail.class);
        util.exportExcel(response, list, "库存盘点详情数据");
    }

    /**
     * 获取库存盘点详情详细信息
     */
    @RequiresPermissions("store:StockTakingDetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(stockTakingDetailService.selectStockTakingDetailById(id));
    }

    /**
     * 新增库存盘点详情
     */
    @RequiresPermissions("store:StockTakingDetail:add")
    @Log(title = "库存盘点详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockTakingDetail stockTakingDetail)
    {
        return toAjax(stockTakingDetailService.insertStockTakingDetail(stockTakingDetail));
    }

    /**
     * 修改库存盘点详情
     */
    @RequiresPermissions("store:StockTakingDetail:edit")
    @Log(title = "库存盘点详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockTakingDetail stockTakingDetail)
    {
        return toAjax(stockTakingDetailService.updateStockTakingDetail(stockTakingDetail));
    }

    /**
     * 删除库存盘点详情
     */
    @RequiresPermissions("store:StockTakingDetail:remove")
    @Log(title = "库存盘点详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(stockTakingDetailService.deleteStockTakingDetailByIds(ids));
    }
}
